package code;

import java.util.ArrayList;

public class QuestionNum_06_5 {
    public static void main(String[] args) {
        student stu1 = new student();
        student stu2 = new student();
        student stu3 = new student();

        stu1.name = "jack";stu1.sex = "男";stu1.age = 28;
        stu2.name = "tom";stu2.sex = "男";stu2.age = 18;
        stu3.name = "rose";stu3.sex = "女";stu3.age = 38;

        ArrayList<student> arr = new ArrayList<student>();
        arr.add(stu1);
        arr.add(stu2);
        arr.add(stu3);

        for(int i=0;i<arr.size();i++)
        {
            System.out.println(arr.get(i).name+" "+arr.get(i).sex+" "+arr.get(i).age);
        }
        int maxAge = 0;
        for(int i=0;i<arr.size();i++)
        {
            if (maxAge < arr.get(i).age) {
                maxAge = arr.get(i).age;
            }
        }

        for(int i=0;i<arr.size();i++)
        {
            if(maxAge == arr.get(i).age){
                System.out.println(arr.get(i).name);
                arr.get(i).name = "葫芦娃";
            }
        }

        for(int i=0;i<arr.size();i++)
        {
            System.out.println(arr.get(i).name+" "+arr.get(i).sex+" "+arr.get(i).age);
        }
    }
}
